{% extends "base.html" %}

{% block title %}登录 - 设备管理系统{% endblock %}

{% block styles %}
<style>
    body {
        background: linear-gradient(135deg, var(--banner-color) 0%, var(--primary-color) 100%);
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 2rem;
    }
    
    .login-container {
        max-width: 420px;
        width: 100%;
        margin: 0 auto;
        padding: 2.5rem;
        background: rgba(255, 255, 255, 0.98);
        border-radius: 16px;
        box-shadow: var(--shadow-lg);
        backdrop-filter: blur(10px);
        animation: slideUp 0.5s ease-out;
    }
    
    @keyframes slideUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .login-header {
        text-align: center;
        margin-bottom: 2rem;
    }
    
    .login-header h1 {
        color: var(--banner-color);
        font-size: 1.8rem;
        font-weight: 700;
        margin-bottom: 0.5rem;
        letter-spacing: 0.5px;
    }
    
    .login-header p {
        color: var(--text-secondary);
        font-size: 0.95rem;
        margin: 0;
    }
    
    .form-group {
        margin-bottom: 1.5rem;
    }
    
    .form-group label {
        display: block;
        margin-bottom: 0.5rem;
        color: var(--text-primary);
        font-weight: 500;
        font-size: 0.95rem;
    }
    
    .form-control {
        width: 100%;
        padding: 0.8rem 1rem;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        font-size: 1rem;
        transition: all var(--transition-speed) ease;
        background-color: white;
        box-sizing: border-box;
    }
    
    .form-control:focus {
        border-color: var(--accent-color);
        box-shadow: 0 0 0 3px rgba(57, 73, 171, 0.1);
    }
    
    .form-control::placeholder {
        color: #a0aec0;
    }
    
    .btn-login {
        width: 100%;
        padding: 0.8rem;
        background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
        color: white !important;
        border: none;
        border-radius: 8px;
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        transition: all var(--transition-speed) ease;
        margin-top: 1rem;
    }
    
    .btn-login:hover {
        transform: translateY(-1px);
        box-shadow: var(--shadow-md);
        background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    }
    
    .btn-login:active {
        transform: translateY(0);
    }
    
    .login-footer {
        text-align: center;
        margin-top: 2rem;
        padding-top: 1.5rem;
        border-top: 1px solid var(--border-color);
        background: transparent;
    }
    
    .login-footer p {
        color: var(--text-secondary);
        font-size: 0.9rem;
        margin: 0;
    }
    
    .card-footer {
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
    }
    
    .text-muted {
        color: var(--text-secondary) !important;
    }
    
    .input-group {
        position: relative;
        width: 100%;
        box-sizing: border-box;
    }
    
    .input-group i {
        position: absolute;
        left: 1rem;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-secondary);
    }
    
    .input-group .form-control {
        padding-left: 2.8rem;
    }
    
    @media (max-width: 576px) {
        body {
            padding: 1rem;
        }
        
        .login-container {
            padding: 2rem;
        }
        
        .login-header h1 {
            font-size: 1.5rem;
        }
    }
</style>
{% endblock %}

{% block content %}
<div class="login-container">
    <div class="login-header">
        <h1><i class="fas fa-server"></i> 设备管理系统</h1>
        <p>请登录以继续操作</p>
    </div>
    
    <form method="POST" action="{{ url_for('login') }}">
        <div class="form-group">
            <label for="username">用户名</label>
            <div class="input-group">
                <i class="fas fa-user"></i>
                <input type="text" class="form-control" id="username" name="username" required 
                       placeholder="请输入用户名">
            </div>
        </div>
        
        <div class="form-group">
            <label for="password">密码</label>
            <div class="input-group">
                <i class="fas fa-lock"></i>
                <input type="password" class="form-control" id="password" name="password" required 
                       placeholder="请输入密码">
            </div>
        </div>
        
        <button type="submit" class="btn-login">
            <i class="fas fa-sign-in-alt"></i> 登录
        </button>
    </form>
    
    <div class="login-footer">
        <p></p>
    </div>
</div>
{% endblock %}

{% block scripts %}
<script>
    // 自动聚焦用户名输入框
    document.addEventListener('DOMContentLoaded', function() {
        document.getElementById('username').focus();
    });
    
    // 表单验证
    document.querySelector('form').addEventListener('submit', function(e) {
        const username = document.getElementById('username').value.trim();
        const password = document.getElementById('password').value.trim();
        
        if (!username || !password) {
            e.preventDefault();
            alert('请输入用户名和密码');
        }
    });
</script>
{% endblock %}